<?php
/**
 * 真题管理
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-6-17
 * Time: 下午2:37
 */
namespace app\modules\applets\controllers;

use yii;
use app\libs\Method;
use app\libs\ApiControl;

class UserController extends ApiControl {

	public $layout = 'applets';
	
    /**
     * [actionIndex description]
     * @Author don
     * @Date   2022-02-22
     * @return [type]     [description]
     */
    public function actionIndex()
    {
        $page = Yii::$app->request->get('page', 1);
        $phone = Yii::$app->request->get('phone', '');
        $pageSize = 10;
        // $data = json_decode(file_get_contents("https://ielts.thinkwithu.com/listen/api/get-users?page=$page&pageSize=$pageSize&phone=$phone"), true);
        $data = json_decode(file_get_contents("https://ielts.thinkwithu.com/listen/api/get-users?page=$page&pageSize=$pageSize&phone=$phone"), true);
        $pageStr = Method::getPagedRows(['count'=>$data['count'],'pageSize'=>$pageSize, 'rows'=>'models']);

        return $this->render('index', [
            'phone' => $phone,
            'data' => $data['data'],
            'pageStr' => $pageStr
        ]);
    }

    /**
     * [actionHandleUser description]
     * @Author don
     * @Date   2022-02-22
     * @return [type]     [description]
     */
    public function actionHandleUser()
    {
        $id = Yii::$app->request->get('id');
        $data = json_decode(file_get_contents("https://ielts.thinkwithu.com/listen/api/handle-user?id=$id"), true);
        
        $this->redirect(['index']);
    }
}